package com.xxchat.entity.enums;

import com.xxchat.utils.StringTools;
import lombok.Getter;

@Getter
public enum UserContactStatusEnum {
    NOT_FRIEND(0, "非好友"),
    FRIEND(1, "好友"),
    DEL(2, "已删除好友"),
    DEL_BE(3, "被好友删除"),
    BLACKLIST(4, "已拉黑好友"),
    BLACKLIST_BE(5, "被好友拉黑"),
    MYSELF(6, "自己");

    private final Integer status;
    private final String desc;

    UserContactStatusEnum(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static UserContactStatusEnum getByStatus(Integer status) {
        for(UserContactStatusEnum item : UserContactStatusEnum.values()) {
            if(item.getStatus().equals(status)) {
                return item;
            }
        }
        return null;
    }

    public static UserContactStatusEnum getByDesc(String desc) {
        try {
            if(StringTools.isEmpty(desc)) {
                return null;
            }
            return UserContactStatusEnum.valueOf(desc.toUpperCase());
        } catch (Exception e) {
            return null;
        }
    }

}
